package com.campus.service.impl;


import com.campus.service.PermService;

import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author HLQ
 * @date 2024/11/23 2:33
 * @todo：开始测试URL权限
 */
@Service
public class PermServiceImpl implements PermService {

    @Override
    public List<String> findPermsByRoleName(List<String> roleNames) {
        List<String> perms = new ArrayList<>();
        // 如果角色是 "admin"，则返回user,activity,class,teacher,student权限
        if (roleNames.contains("admin") ) {
            //users
            perms.add("sat_mid_proj_campus/users/id/search");
            perms.add("sat_mid_proj_campus/users/name/search");
            perms.add("sat_mid_proj_campus/users/roles/users");
            perms.add("sat_mid_proj_campus/users/roles");
            perms.add("sat_mid_proj_campus/users/permissions");
            perms.add("sat_mid_proj_campus/users/groups");
            perms.add("sat_mid_proj_campus/users/groups");
            //activities
            perms.add("sat_mid_proj_campus/activities");
            perms.add("sat_mid_proj_campus/activities/update");
            perms.add("sat_mid_proj_campus/activities/publish");
            perms.add("sat_mid_proj_campus/activities//search");
            //classes
            perms.add("sat_mid_proj_campus/classes");
            perms.add("sat_mid_proj_campus/classes/id/update");
            perms.add("sat_mid_proj_campus/classes/students/groups");
            perms.add("sat_mid_proj_campus/classes/teachers");
            //teachers
            perms.add("sat_mid_proj_campus/teachers/search");
            //students
            perms.add("sat_mid_proj_campus/students/check");
            // 其他权限
        }

        // 如果角色是 "assistant"，则返回教辅权限
        if (roleNames.contains("assistant")) {
            perms.add("sat_mid_proj_campus/assistants/classes/students/groups/");

        }

        // 如果角色是 "teacher"，则只返回teacher权限
        if (roleNames.contains("teacher")) {
            perms.add("sat_mid_proj_campus/teachers/courses");
        }
        // 如果角色是 "student"，则只返回student权限
        if (roleNames.contains("sat_mid_proj_campus/student")) {
        }
        // 如果没有匹配的角色，返回空权限
        return perms.isEmpty() ? List.of() : perms;

    }
}
